package com.htthorizon.task;

import cn.hutool.core.date.DateTime;
import com.htthorizon.common.log.enums.BusinessStatus;
import com.htthorizon.common.log.service.AsyncLogService;
import com.htthorizon.model.controller.TestController;
import com.htthorizon.system.api.domain.SysOperLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author Brilliant
 */
@Component
@Slf4j
public class DATASync {

    @Autowired
    private TestController testController;

    @Autowired
    private AsyncLogService asyncLogService;


    @Scheduled(cron = "0 0 1 1 1,6 ?")
    public void task() throws Exception {
        long start = System.currentTimeMillis();
        testController.test();
        testController.test1();
        SysOperLog operLog = new SysOperLog();
        operLog.setTitle("自动同步数据");
        operLog.setType("系统类");
        operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
        operLog.setCostTime(System.currentTimeMillis() - start);
        operLog.setCreateTime(DateTime.now());
        asyncLogService.saveSysLog(operLog);
    }
}
